<?php
class Admin_AdmintratorController extends My_Controller_Admin_Choix
{
	public function indexAction()
	{
	    $model = Mage::getModel('admin/users');

		$this->view->collection = $model->getCollection();
	}

	public function editAction()
	{
	    $userId = $this->_getParam('id', 0);
	    $user = Mage::getModel('admin/users');
	    if ($userId) {
	        $user->load($userId);
	    }
	    $this->view->object = $user;
	    $this->view->listVentes = $user->getListVentes();
	}

	public function newAction()
	{
	    $this->_forward('edit');
	}

	public function saveAction()
	{
	    $id = $this->_getParam('id');
	    $model = Mage::getModel('admin/users');
	    if ($id) {
	        $model->load($id);
	    }
	    $userData = $this->_getParam('user');
	    $model->addData($userData)->save();
	    $this->_redirect('admin/admintrator/?num_vente=' . $this->view->numVente);
	    exit;
	}

	public function deleteAction()
	{
	    $id = $this->_getParam('id');
	    if ($id == 1) {
	        $this->_redirect('admin/admintrator/?num_vente=' . $this->view->numVente);
	    }
	    Mage::getModel('admin/users')->load($id)->delete();
	    $this->_redirect('admin/admintrator/?num_vente=' . $this->view->numVente);
	    exit;
	}
}

